home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / misc / date.lha / Date / C / src / test.c < prev    next >
C/C++ Source or Header  |  1994-08-02  |  14KB  |  402 lines

  1.  #include <stdio.h>
  2.  #include "Date.h"
  3.  
  4.  
  5.  int readintyear(void)
  6.  
  7.  {int year=0;
  8.  
  9.   printf("(integer)year: ");
  10.   scanf("%d",&year);
  11.   return(year);
  12.  }
  13.  
  14.  
  15.  unsigned short readshortcardmonth(void)
  16.  
  17.  {unsigned int month=0;
  18.  
  19.   printf("(shortcard)month: ");
  20.   scanf("%u",&month);
  21.   return((unsigned short)month);
  22.  }
  23.  
  24.  
  25.  unsigned short readshortcardday(void)
  26.  
  27.  {unsigned int day=0;
  28.  
  29.   printf("(shortcard)day: ");
  30.   scanf("%u",&day);
  31.   return((unsigned short)day);
  32.  }
  33.  
  34.  
  35.  Weekdays readweekday(void)
  36.  
  37.  {unsigned int wday=0;
  38.  
  39.   do
  40.    {printf("weekday: 1=Monday; ...7=Sunday: ");
  41.     scanf("%u",&wday);
  42.    }
  43.   while (wday > 7);
  44.   return((Weekdays)wday);
  45.  }
  46.  
  47.  
  48.  Weekdays readintdays(void)
  49.  
  50.  {int days=0;
  51.  
  52.   printf("(integer)days: ");
  53.   scanf("%d",&days);
  54.   return(days);
  55.  }
  56.  
  57.  
  58.  unsigned int readcardyear(void)
  59.  
  60.  {unsigned int year=0;
  61.  
  62.   printf("(cardinal)year: ");
  63.   scanf("%u",&year);
  64.   return(year);
  65.  }
  66.  
  67.  
  68.  unsigned long readlongcarddays(void)
  69.  
  70.  {unsigned long day=0;
  71.  
  72.   printf("(longcard)days: ");
  73.   scanf("%u",&day);
  74.   return(day);
  75.  }
  76.  
  77.  
  78.  unsigned short readshortcardhour(void)
  79.  
  80.  {unsigned int hour=0;
  81.  
  82.   printf("(shortcard)hour: ");
  83.   scanf("%u",&hour);
  84.   return((unsigned short)hour);
  85.  }
  86.  
  87.  
  88.  unsigned short readshortcardmin(void)
  89.  
  90.  {unsigned int min=0;
  91.  
  92.   printf("(shortcard)min: ");
  93.   scanf("%u",&min);
  94.   return((unsigned short)min);
  95.  }
  96.  
  97.  
  98.  unsigned short readshortcardsec(void)
  99.  
  100.  {unsigned int sec=0;
  101.  
  102.   printf("(shortcard)sec: ");
  103.   scanf("%u",&sec);
  104.   return((unsigned short)sec);
  105.  }
  106.  
  107.  
  108.  float readrealtime(void)
  109.  
  110.  {float jd=0.0;
  111.  
  112.   printf("(real)time: ");
  113.   scanf("%f",&jd);
  114.   return(jd);
  115.  }
  116.  
  117.  
  118.  short readshortintdegree(void)
  119.  
  120.  {int degree=0;
  121.  
  122.   printf("(shortint)degree: ");
  123.   scanf("%d",°ree);
  124.   return((short)degree);
  125.  }
  126.  
  127.  
  128.  unsigned long readlongcardsecs(void)
  129.  
  130.  {unsigned long secs=0;
  131.  
  132.   printf("(longcard)secs: ");
  133.   scanf("%u",&secs);
  134.   return(secs);
  135.  }
  136.  
  137.  
  138.  float readrealmeridian(void)
  139.  
  140.  {float jd=0.0;
  141.  
  142.   printf("(real)meridian: ");
  143.   scanf("%f",&jd);
  144.   return(jd);
  145.  }
  146.  
  147.  
  148.  float readrealpos(void)
  149.  
  150.  {float jd=0.0;
  151.  
  152.   printf("(real)ps: ");
  153.   scanf("%f",&jd);
  154.   return(jd);
  155.  }
  156.  
  157.  
  158.  void main(void)
  159.  
  160.  {unsigned int        input=0,repeat=0;
  161.   Weekdays        wd;
  162.   unsigned short    d=0,m=0,h=0,s=0;
  163.   int            y=0;
  164.  
  165.   #ifndef __SASC_650
  166.     _DateInit();
  167.   #endif
  168.   do
  169.    {printf("----------------------------------------------------------------\n");
  170.     printf("01 : JulianLeapYear            | 02 : GregorianLeapYear\n");
  171.     printf("03 : HeisLeapYear              | 04 : JulianMonthDays\n");
  172.     printf("05 : GregorianMonthDays        | 06 : HeisMonthDays\n");
  173.     printf("07 : JulianYearDays            | 08 : GregorianYearDays\n");
  174.     printf("09 : HeisYearDays              | 10 : JulianDayDiff\n");
  175.     printf("11 : GregorianDayDiff          | 12 : HeisDayDiff\n");
  176.     printf("13 : JulianDaySmaller          | 14 : GregorianDaySmaller\n");
  177.     printf("15 : HeisDaySmaller            | 16 : JulianWeekday\n");
  178.     printf("17 : GregorianWeekday          | 18 : HeisWeekday\n");
  179.     printf("19 : JulianDaysBeforeWeekday   | 20 : GregorianDaysBeforeWeekday\n");
  180.     printf("21 : HeisDaysBeforeWeekday     | 22 : JulianDaysAfterWeekday\n");
  181.     printf("23 : GregorianDaysAfterWeekday | 24 : HeisDaysAfterWeekday\n");
  182.     printf("25 : JulianDiffDate            | 26 : GregorianDiffDate\n");
  183.     printf("27 : HeisDiffDate              | 28 : JYearToScaliger\n");
  184.     printf("29 : GYearToScaliger           | 30 : HYearToScaliger\n");
  185.     printf("31 : ScaligerYearToJ           | 32 : ScaligerYearToG\n");
  186.     printf("33 : ScaligerYearToH           | 34 : JSYearToJD\n");
  187.     printf("35 : GSYearToJD                | 36 : HSYearToJD\n");
  188.     printf("37 : JDtoMJD                   | 38 : MJDtoJD\n");
  189.     printf("39 : JulianToJD                | 40 : GregorianToJD\n");
  190.     printf("41 : HeisToJD                  | 42 : TimeToJD\n");
  191.     printf("43 : JDToTime                  | 44 : GregorianMoonAge\n");
  192.     printf("45 : GregorianEaster           | 46 : TimeZoneFactor\n");
  193.     printf("47 : LMT                       | 48 : TimeToSec\n");
  194.     printf("49 : SecToTime                 | 50 : JulianWeek\n");
  195.     printf("51 : GregorianWeek             | 52 : HeisWeek\n");
  196.     printf("00 : Quit\n");
  197.     printf("It's your turn: ");
  198.     scanf("%u",&input);
  199.     printf("----------------------------------------------------------------\n");
  200.     do
  201.      {switch (input)
  202.         {
  203.          case  0 : break;
  204.          case  1 : if (JulianLeapYear(readintyear()))
  205.                      printf("TRUE\n");
  206.                 else
  207.                   printf("FALSE\n");
  208.                break;
  209.          case  2 : if (GregorianLeapYear(readintyear()))
  210.                  printf("TRUE\n");
  211.                 else
  212.                   printf("FALSE\n");
  213.                    break;
  214.          case  3 : if (HeisLeapYear(readintyear()))
  215.                   printf("TRUE\n");
  216.                 else
  217.                   printf("FALSE\n");
  218.                break;
  219.          case  4 : printf("%u\n",JulianMonthDays(readshortcardmonth(),readintyear()));
  220.                    break;
  221.          case  5 : printf("%u\n",GregorianMonthDays(readshortcardmonth(),readintyear()));
  222.                    break;
  223.          case  6 : printf("%u\n",HeisMonthDays(readshortcardmonth(),readintyear()));
  224.                    break;
  225.          case  7 : printf("%u\n",JulianYearDays(readintyear()));
  226.                    break;
  227.          case  8 : printf("%u\n",GregorianYearDays(readintyear()));
  228.                break;
  229.          case  9 : printf("%u\n",HeisYearDays(readintyear()));
  230.                break;
  231.          case 10 : printf("%d\n",JulianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()));
  232.                break;
  233.          case 11 : printf("%d\n",GregorianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()));
  234.                break;
  235.          case 12 : printf("%d\n",HeisDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()));
  236.                break;
  237.          case 13 : if (JulianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()))
  238.                   printf("TRUE\n");
  239.                 else
  240.                   printf("FALSE\n");
  241.                break;
  242.          case 14 : if (GregorianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()))
  243.                   printf("TRUE\n");
  244.                 else
  245.                   printf("FALSE\n");
  246.                break;
  247.          case 15 : if (HeisDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()))
  248.                   printf("TRUE\n");
  249.                 else
  250.                   printf("FALSE\n");
  251.                break;
  252.          case 16 : wd = JulianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  253.                      switch (wd)
  254.                        {case dayerr    : printf("dayerr!\n");
  255.                                    break;
  256.                       case Monday    : printf("Monday\n");
  257.                                    break;
  258.                       case Tuesday   : printf("Tuesday\n");
  259.                                    break;
  260.                       case Wednesday : printf("Wednesday\n");
  261.                                    break;
  262.                       case Thursday  : printf("Thursday\n");
  263.                                    break;
  264.                       case Friday    : printf("Friday\n");
  265.                                    break;
  266.                       case Saturday  : printf("Saturday\n");
  267.                                    break;
  268.                       case Sunday    : printf("Sunday\n");
  269.                                        break;
  270.                       default        : printf("Illegal Code!\n");
  271.                      }
  272.                break;
  273.          case 17 : wd = GregorianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  274.                      switch (wd)
  275.                        {case dayerr    : printf("dayerr!\n");
  276.                                    break;
  277.                       case Monday    : printf("Monday\n");
  278.                                    break;
  279.                       case Tuesday   : printf("Tuesday\n");
  280.                                    break;
  281.                       case Wednesday : printf("Wednesday\n");
  282.                                    break;
  283.                       case Thursday  : printf("Thursday\n");
  284.                                    break;
  285.                       case Friday    : printf("Friday\n");
  286.                                    break;
  287.                       case Saturday  : printf("Saturday\n");
  288.                                    break;
  289.                       case Sunday    : printf("Sunday\n");
  290.                                        break;
  291.                       default        : printf("Illegal Code!\n");
  292.                      }
  293.                break;
  294.          case 18 : wd = HeisWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  295.                      switch (wd)
  296.                        {case dayerr    : printf("dayerr!\n");
  297.                                    break;
  298.                       case Monday    : printf("Monday\n");
  299.                                    break;
  300.                       case Tuesday   : printf("Tuesday\n");
  301.                                    break;
  302.                       case Wednesday : printf("Wednesday\n");
  303.                                    break;
  304.                       case Thursday  : printf("Thursday\n");
  305.                                    break;
  306.                       case Friday    : printf("Friday\n");
  307.                                    break;
  308.                       case Saturday  : printf("Saturday\n");
  309.                                    break;
  310.                       case Sunday    : printf("Sunday\n");
  311.                                        break;
  312.                       default        : printf("Illegal Code!\n");
  313.                      }
  314.                break;
  315.          case 19 : printf("%u\n",JulianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  316.                break;
  317.          case 20 : printf("%u\n",GregorianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  318.                break;
  319.          case 21 : printf("%u\n",HeisDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  320.                break;
  321.          case 22 : printf("%u\n",JulianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  322.                break;
  323.          case 23 : printf("%u\n",GregorianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  324.                break;
  325.          case 24 : printf("%u\n",HeisDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()));
  326.                break;
  327.          case 25 : JulianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),&d,&m,&y);
  328.                    printf("%u.%u.%d\n",d,m,y);
  329.                break;
  330.          case 26 : GregorianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),&d,&m,&y);
  331.                    printf("%u.%u.%d\n",d,m,y);
  332.                break;
  333.          case 27 : HeisDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),&d,&m,&y);
  334.                    printf("%u.%u.%d\n",d,m,y);
  335.                break;
  336.          case 28 : printf("%u\n",JYearToScaliger(readintyear()));
  337.                break;
  338.          case 29 : printf("%u\n",GYearToScaliger(readintyear()));
  339.                break;
  340.          case 30 : printf("%u\n",HYearToScaliger(readintyear()));
  341.                break;
  342.          case 31 : printf("%d\n",ScaligerYearToJ(readcardyear()));
  343.                break;
  344.          case 32 : printf("%d\n",ScaligerYearToG(readcardyear()));
  345.                break;
  346.          case 33 : printf("%d\n",ScaligerYearToH(readcardyear()));
  347.                break;
  348.          case 34 : printf("%u\n",JSYearToJD(readcardyear()));
  349.                break;
  350.          case 35 : printf("%u\n",GSYearToJD(readcardyear()));
  351.                break;
  352.          case 36 : printf("%u\n",HSYearToJD(readcardyear()));
  353.                break;
  354.          case 37 : printf("%u\n",JDtoMJD(readlongcarddays()));
  355.                break;
  356.          case 38 : printf("%u\n",MJDtoJD(readlongcarddays()));
  357.                break;
  358.          case 39 : printf("%u\n",JulianToJD(readshortcardday(),readshortcardmonth(),readintyear()));
  359.                break;
  360.          case 40 : printf("%u\n",GregorianToJD(readshortcardday(),readshortcardmonth(),readintyear()));
  361.                break;
  362.          case 41 : printf("%u\n",HeisToJD(readshortcardday(),readshortcardmonth(),readintyear()));
  363.                break;
  364.          case 42 : printf("%f\n",TimeToJD(readshortcardhour(),readshortcardmin(),readshortcardsec()));
  365.                    break;
  366.          case 43 : JDToTime(readrealtime(),&h,&m,&s);
  367.                    printf("%u:%u:%u\n",h,m,s);
  368.                break;
  369.          case 44 : printf("%u\n",GregorianMoonAge(readshortcardday(),readshortcardmonth(),readintyear()));
  370.                break;
  371.          case 45 : GregorianEaster(readintyear(),&d,&m);
  372.                    printf("%u.%u.\n",d,m);
  373.                break;
  374.          case 46 : printf("%d\n",TimeZoneFactor(readshortintdegree()));
  375.                break;
  376.          case 47 : printf("%d\n",LMT(readlongcardsecs(),readrealmeridian(),readrealpos()));
  377.                break;
  378.          case 48 : printf("%u\n",TimeToSec(readshortcardhour(),readshortcardmin(),readshortcardsec()));
  379.                break;
  380.          case 49 : SecToTime(readlongcardsecs(),&h,&m,&s);
  381.                    printf("%u:%u:%u\n",h,m,s);
  382.                break;
  383.      case 50 : printf("%u\n",JulianWeek(readshortcardday(),readshortcardmonth(),readintyear()));
  384.            break;
  385.      case 51 : printf("%u\n",GregorianWeek(readshortcardday(),readshortcardmonth(),readintyear()));
  386.            break;
  387.      case 52 : printf("%u\n",HeisWeek(readshortcardday(),readshortcardmonth(),readintyear()));
  388.            break;
  389.          default : printf("Wong number! Try again!\n");
  390.         }
  391.       if (input > 0)
  392.         {printf("0 : Menue; >0 : test again - ");
  393.          scanf("%u",&repeat);
  394.         }
  395.       else
  396.         repeat = 0;
  397.      }
  398.     while (repeat != 0);
  399.    }
  400.   while (input != 0);
  401.  }
  402.